home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEM / I-M / LineShare DEMO.sea / LineShare Scripts / EXAR Fax&MultiData < prev    next >
Text File  |  1992-12-02  |  6KB  |  282 lines

  1. !
  2. ! LineShare™ Script for 2400/9600 data-fax modems (EXAR-based)
  3. !
  4. ! This script is designed to use with fax and several data services:
  5. ! TeleFinder™ BBS ("TF" subPort)
  6. ! QuickMail™ MailServer ("Mail" subPort)
  7. ! the choice is done manually, by the user, when connecting to the host
  8. ! The script displays menu: this lines are marked with "@@@"
  9. !
  10. ! For some reasons TeleFinder redefines the LineFeed character (S4)
  11. ! We don't redefine it really, but we emulate modem responses with that symbol
  12. ! This trick is done in lines marked with '$$$$'
  13. !
  14. ! If you want to modify this script for your modem, pay attention to
  15. ! the line marked "#### Settings ####" - it should be modified first
  16. !
  17. ! The TeleFinder "Host Options" used:
  18. ! "Adjust BPS to line speed" - *disabled* (since we alsways return "CONNECT 19200")
  19. ! "Use Break Reset" - *enabled*,
  20. ! LineShare "Options…" for the "TF" subport:
  21. ! Disconnect when "Sends Break" - enabled.  (since we've enabled "Use Break Reset")
  22. !
  23. ! The QuickMail options (through CTB module:)
  24. ! Don't adjust speed (since we alsways return "CONNECT 19200")
  25. ! LineShare "Options…" for the "Mail" subport:
  26. ! "Resets Port" - disabled, since the CTB tool uses to reset it
  27. !
  28. !
  29.  
  30. ! ------------------------------------------
  31. ! Resetting the modem:
  32. ! ------------------------------------------
  33. @Hangup
  34.   SetTries 2
  35.   Flush
  36.   HsReset 0,0,17,19,0,0
  37. !
  38. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  39. ! to enter the command mode
  40. !
  41. @Label 1
  42.   matchclr
  43.   matchstr 1 2 "OK\r\n"
  44.   write "ATH0&F\r"
  45.   matchread 20
  46.   Write "+++"
  47.   DtrClear
  48.   pause 10
  49.   DtrSet
  50. !
  51.   DecTries
  52.   IfTries 0 1
  53. !
  54. ! OSErr -6019 "Modem error - the modem is not responding"
  55. !
  56.   exit -6019
  57. @Label 2
  58.   write "AT+FCLASS=0\r"
  59.   Jsr 100
  60.   write "AT+FAA=0\r"
  61.   Jsr 100
  62.   exit 0
  63. ! ------------------------------------------
  64. !    Receiving incoming calls
  65. ! ------------------------------------------
  66. @ANSWER
  67. @Label 10
  68. !
  69. ! Set the modem preferred speed first
  70. !
  71.   SERRESET 2400,0,8,1
  72.   Jsr 80
  73. !
  74. ! Set the common options
  75.   Jsr 70
  76. !
  77. ! Set the communication options:
  78. ! Extended response set
  79. ! Enable MNP for TeleFinder
  80. ! Xon/Xoff flow control (for Fax)
  81. ! Fax mode (to enable fax tuning commands)
  82. !
  83. @Label 11
  84. ! #### Settings ####
  85.   Write "ATX4\\N3\\Q1&S1+FCLASS=2\r"
  86.   Jsr 100
  87. !
  88. ! Set the "work" speed
  89. !
  90. @Label 12
  91.   SERRESET 19200,0,8,1
  92.   Jsr 80
  93. !
  94. ! Set Fax parameters: LID, DCC,BOR
  95. !
  96.   Write "AT+FLID=\"Stalker_GmbH\"\r"
  97.   Jsr 100
  98.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  99.   Jsr 100
  100.   Write "AT+FBOR=1\r"
  101.   Jsr 100
  102. !
  103. ! Allow modem to receive fax messages
  104. !
  105.   Write "AT+FCR=1\r"
  106.   Jsr 100
  107. !
  108. ! Tell the modem to determine the type of the incoming call
  109. ! Fetch the tube after N rings, where N has been set in the control panel (^4)
  110. !
  111.   Write "ATS0=^4+FAA=1\r"
  112.   Jsr 100
  113. !
  114. ! Everything is ready - let's sit and wait for a call
  115. ! We'll wait for 2 minutes, then reinitiate the modem
  116. @Label 20
  117.   MatchClr
  118.   matchstr 1 20 "RING\r"
  119.   matchstr 2 21 "CONNECT"
  120.   matchstr 13 30 "+FCON"
  121.   matchstr 14 10 "\r\nNO  "
  122.   matchstr 15 10 "BUSY"
  123.   Matchread 1200
  124.   jump 10
  125. !
  126. ! Data connection has been established (we read "CONNECT")
  127. ! Remove everything till "\r\n" from the buffer
  128. @Label 21
  129.   MatchClr
  130.   MatchStr 1 22 "\r\n"
  131.   MatchRead 10
  132.   exit -6019
  133. @Label 22
  134. !
  135. ! Display our menu
  136. ! @@@
  137.   Write "\r\n\n\n\nWelcome to Stalker Multi-Service Host!\r\n"
  138.   Write "\r\nPress a key to connect to:\r\n"
  139.   Write "M - TeleFinder(tm) BBS\r\n"
  140.   Write "Q - QuickMail(tm) mail-server\r\n"
  141.   Write "=>"
  142.   MatchClr
  143.   MatchStr 1 24 "M"
  144.   MatchStr 2 24 "m"
  145.   MatchStr 3 25 "Q"
  146.   MatchStr 4 25 "q"
  147.   MatchStr 5 23 "\r"
  148.   MatchRead 150
  149. @Label 23
  150.   exit -6019
  151. !
  152. ! Emulate the CONNECT 19200 message
  153. ! Attach the "TF" subPort
  154. ! The letter "M" is also put into the buffer,
  155. ! since it could be part of TeleFinder "MMM" 'entry mark'
  156. !
  157. @Label 24
  158.   Write "M\r\n\r\nConnecting to TeleFinder...\r\n"
  159.   QueueInput "\r\27CONNECT 19200\r\27M"
  160.   Attach "TF" (DTR,BREAK,RESET,ESCAPE,IDLELIMIT=60)
  161. !
  162. ! Emulate the CONNECT 19200 message
  163. ! Attach the "Mail" subPort
  164. ! The symbol "\r" is also put into the buffer,
  165. ! to force QuickMail to start the session
  166. !
  167. @Label 25
  168.   Write "Q\r\n\r\nConnecting to QuickMail...\r\n"
  169.   QueueInput "\r\nCONNECT 19200\r\n\r"
  170.   Attach "Mail" (DTR,ESCAPE)
  171. !
  172. ! Fax connection has been established (we read "+FCON")
  173. ! Put the +FCON back to the buffer,
  174. ! Put the "RING" before the "+FCON"
  175. ! Attach the "Fax" subPort
  176. !
  177. @Label 30
  178.   QueueInput "\r\nRING\r\n\r\n+FCON"
  179.   Attach "Fax" (DTR,RESET,ESCAPE,IDLELimit=30)
  180. ! ------------------------------------------
  181. ! Originating a call through the "Fax" subPort
  182. ! ------------------------------------------
  183. @ORIGINATE "Fax"
  184. !
  185. ! Set the "Fax" speed
  186. !
  187.   SERRESET 19200,0,8,1
  188.   Jsr 80
  189. !
  190. ! Set the common options
  191. !
  192.   Jsr 70
  193. !
  194. ! Set the Fax mode
  195. !
  196.   Write "AT+FCLASS=2\r"
  197.   Jsr 100
  198. !
  199. ! Now emit all commands that the application has sent to that port,
  200. ! Prepare to receive all error result codes
  201. !
  202. !EmitClear "S","S","S","&","&","\\","\\"
  203.   Jsr 60
  204. !
  205. ! Prepare to connect
  206. !
  207.   Jsr 90
  208.   MatchStr 1 51 "\r\n+FCON"
  209.   HsReset *
  210.   Write "ATD^1\r"
  211.   MatchRead 700
  212.   Write "\r"
  213.   Exit -6019
  214. @LABEL 51
  215.   QueueInput "\r\n+FCON"
  216.   Attach "Fax" (DTR,RESET,ESCAPE,IDLELimit=30)
  217. !
  218. ! This section emits all modem commands sent by the client application
  219. ! For each set of commands the "OK" answer is awaited
  220. !
  221. @Label 60
  222.   EmitStart
  223. @Label 61
  224.   EmitCommand 62
  225.   Jsr 100
  226.   Jump 61
  227. @Label 62
  228.   return
  229. !
  230. ! This section initiates the modem before ANSWER and ORIGINATEs:
  231. ! factory settings + speaker control +
  232. ! reset on Dtr drop + DCD valid
  233. ! Verbal responses mode, no echo 
  234. ! Set &S1 (DSR) in case the cable connects the DSR signal with the CTS pin
  235. !
  236. @Label 70
  237.   Write "ATM^2L^3&D2&C1V1E0\r"
  238.   Jsr 100
  239.   return 
  240. !
  241. ! This section syncronize the modem after the serial port speed switching
  242. !
  243. @Label 80
  244.   ChrDelay 1
  245.   Write "AT\r"
  246.   ChrDelay 0
  247.   Jsr 100
  248.   return
  249. !
  250. ! Prepare to receive error result codes
  251. !
  252. @Label 90
  253.   MatchClr
  254.   MatchStr 2 91 "NO DIALTONE\r\n"
  255.   MatchStr 3 92 "BUSY\r\n"
  256.   MatchStr 4 93 "NO CARRIER\r\n"
  257.   MatchStr 5 94 "NO ANSWER\r\n"
  258.   return
  259. @Label 91
  260.   exit -6020
  261. @Label 92
  262.   exit -6022
  263. @Label 93
  264.   exit -6021
  265. @Label 94
  266.   exit -6023
  267. !
  268. ! Processing the AT command:
  269. ! OK -> proceed
  270. ! ERROR or TimeOut ->exit -6019
  271. ! It can be called AFTER the "Write" command, since LineShare buffers input
  272. !
  273. @Label 100
  274.   MatchClr
  275.   MatchStr 1 102 "\r\nOK\r\n"
  276.   MatchStr 2 101 "\r\nERROR\r\n"
  277.   MatchRead 20
  278. @Label 101
  279.   Exit -6019
  280. @Label 102
  281.   return
  282.